package day03;
//运算符演示
public class OperDemo {
    public static void main(String[] args) {
        /**
         * 1.算术运算符：+，-，*，/,%,++,--
         * 1)%:取模/取余，余数为0即为整除
         * 2）++/--:自增1/自减1，可前可后
         *      2.1）单独使用：在前在后都一样
         *      2.2）被使用：在前++a=a+1，在后先赋值再运算a++=a
         */
        /*
        System.out.println(5%2);//2.....3
        System.out.println(8%2);//4.....0整除
        System.out.println(2%8);//0.....2

        int a= 5,b = 5;
        int c = a++;
        int d = ++b;
        System.out.println(a);
        System.out.println(b);
        System.out.println(c);
        System.out.println(d);
        System.out.println(a++);//被使用6
        System.out.println(a);//7

         */
        /*
        int a = 5,b = 5;
        a--;
        --b;
        System.out.println(a);
        System.out.println(b);

         */
        /*
        int a = 5,b = 5;
        int c = a--;
        int d = --b;
        System.out.println(a);
        System.out.println(b);
        System.out.println(c);
        System.out.println(d);

         */
        /**
         * 2.关系运算符：
         *      1）>,<,>=,<=,==,!=
         *      2)
         */
        /*
        int a = 5, b = 10, c = 5;
        boolean b1 =a > b;
        System.out.println(b1);
        System.out.println(c<b);
        System.out.println(a>=c);
        System.out.println(a<=b);
        System.out.println(a==c);
        System.out.println(a!=c);

        System.out.println(a%2==0);//false
        System.out.println(a+c>b);//false
        System.out.println(a++>5);//false
        System.out.println(a++>5);//true

         */

        /**
         * 3.逻辑运算符
         *  1）  &&：两边为真则为真
         *      ||：一个为真即为真
         *      ！：取反
         *  2）逻辑运算符是建立在关系运算符之上
         *      逻辑计算结果也是布尔型
         */

        //int a = 5, b = 10, c = 5;
        /*
        boolean b1 = b >= a && b < c;
        System.out.println(b1);
        System.out.println(b<=c && b>a);
        System.out.println(a==b && b<a);
        System.out.println(b!=c && b>c);

        int age = 39;
        //年龄是否在18到50之间
        boolean age1 = age>=18 && age<=50;
        System.out.println(age1);

        int score = 86;
        System.out.println(score >=0 && score <=100);

         */
        /*
        System.out.println(b>=a || b<c);
        System.out.println(b<=c || b>a);
        System.out.println(b!=c || b>a);
        System.out.println(a==b || b<a);
        int score = 90;
        System.out.println(score <0 || score > 100);//成绩不合法验证

        boolean b2 = !(a<b);
        System.out.println(b2);
        System.out.println(!(a>b));

         */
       // boolean b3 = a>b && c++>2;
        //System.out.println(b3);
       // System.out.println(c);
        /**
         *4.赋值运算符
         *  1）简单赋值：=
         *  2）扩展赋值：+=，-=，*=，、=，%=
         *  注意：扩展赋值运算符自带强转功能
         */
        /*
        int a1 = 5;
        a1 += 10;
        System.out.println(a1);
        a1 *= 2;
        System.out.println(a1);
        a1 /= 6;
        System.out.println(a1);
        //小面试题：
        short s = 5;
        //s = s + 10;//编译错误，需要强转
        s += 10;//相当于s=(short)(s+10);

         */
        /**
         * 5.字符串连接：+
         */

        /*
        int  age = 39;
        System.out.println("age");
        System.out.println(age);
        System.out.println("age"+age);
        System.out.println("我今年"+age+"岁了");

        String name = "WKJ";
        System.out.println("大家好，我叫"+name);
        System.out.println("大家好，我叫"+name+",今年"+age+"岁了");

         */

        /**
         * 6.条件/三目运算符：
         *  1）语法
         *      boolean?数1:数2
         *  2）执行过程：
         *      整个表达式是有值的，它的值要么是数1，要么是数2
         *      计算boolean的值：
         *          若为true，则整个表达式的结果为数1
         *          若为false，则整个表达式的结果为数2
         */
        //找两个数中的最大值
        /*
        int a = 8, b = 5;
        int max = a>b?a:b;
        System.out.println(max);

        int num = 0;
        int flag = num>0?1:-1;
        System.out.println(flag);

         */
    }
}
